<?php
namespace app\common\validate;

use think\Validate;

class Agent extends Validate
{
    protected $rule = [
        'agentname'  => 'require|min:1|unique:agent',
        'password'   => 'require|min:6',
        'repassword' => 'require|confirm:password',
        'name'       => 'require|min:1',
        'mobile'     => '/^1[345789]\d{9}$/|unique:agent',
        'status'     => 'require|in:0,1',
    ];

    protected $message = [
        'agentname.require' => '{%agentname_require}',
        'agentname.min'     => '{%agentname_min}',
        'agentname.unique'  => '{%agentname_unique}',
        'password'          => '{%password_val}',
        'password.min'      => '{%password_min}',
        'repassword'        => '{%repassword_val}',
        'name'              => '{%name_val}',
        'name.min'          => '{%name_min}',
        'mobile'            => '{%mobile_val}',
        'mobile.unique'     => '{%mobile_unique}',
        'end_time'          => '{%end_time_val}',
        'status'            => '{%status_val}',
    ];

    protected $scene = [
        'add'   => ['agentname', 'password', 'repassword', 'name', 'mobile', 'status'],
        'edit'  => ['agentname', 'name', 'mobile'],
        'password' => ['password', 'repassword'],
    ];
}